

/**
 * @param {Object} config
 * @param {string} config.title
 * @param {string} config.content
 * @param {string} config.cancelText
 * @param {string} config.confirmText
 * @param {string} config.cancelColor
 * @param {string} config.confirmColor
 */
export function showConfirmDialog(config) {
	config.showCancel = false;
	return showDialog(config);
}

/**
 * @param {Object} config
 * @param {string} config.title
 * @param {string} config.content
 * @param {boolean} config.showCancel
 * @param {string} config.cancelText
 * @param {string} config.confirmText
 * @param {string} config.cancelColor
 * @param {string} config.confirmColor
 */
export function showDialog(config) {
	return new Promise(resolve => {
		uni.showModal({
			title: config.title || "提示",
			content: config.content || "请注意异常",
			showCancel: config.showCancel ?? true,
			cancelText: config.cancelText || "取消",
			confirmText: config.confirmText || "确定",
			// cancelColor: config.cancelColor,
			// confirmColor: config.confirmColor,
			success: function(res) {
				if (res.confirm) {
					resolve(true);
				} else if (res.cancel) {
					resolve(false);
				}
			}
		});

	})
}